package com.weitu.hiddenDanger.service.impl;

import com.weitu.hiddenDanger.entity.Precaution;
import com.weitu.hiddenDanger.mapper.HDPrecautionMapper;
import com.weitu.hiddenDanger.service.HDPrecautionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * Created by fanyuting on 2017/4/11 0011.
 */
@Service
public class HDPrecautionServiceImpl implements HDPrecautionService {
    @Autowired
    private HDPrecautionMapper hdPrecautionMapper;
    /**
     * 查询防范措施分页列表
     * @param map
     * @return
     */
    public List<Map<String,Object>>  queryPrecautionList(Map<String,Object> map){
        return this.hdPrecautionMapper.queryPrecautionList(map);
    }

    /**
     * 查询防范措施列表数量
     * @param map
     * @return
     */
    public int queryPrecautionCount(Map<String,Object> map){
        return this.hdPrecautionMapper.queryPrecautionCount(map);
    }

    /**
     * 新增防范措施
     * @param map
     * @return
     */
    @Transactional
    public boolean addPrecaution(Map<String,Object> map){
        int flag = this.hdPrecautionMapper.addPrecaution(map);
        if(flag<1){
            return false;
        }
        return true;
    }

    /**
     * 删除防范措施
     * @param map
     * @return
     */
    @Transactional
    public boolean deletePrecaution(Map<String,Object> map){
        int flag = this.hdPrecautionMapper.deletePrecaution(map);
        if(flag<1){
            return false;
        }
        return true;
    }

    /**
     * 编辑防范措施
     * @param map
     * @return
     */
    @Transactional
    public boolean editPrecaution(Map<String,Object> map){
        int flag = this.hdPrecautionMapper.editPrecaution(map);
        if(flag<1){
            return false;
        }
        return true;
    }
}
